﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Saxxon.LibDoomSharp.Lumps
{
    public class VertexesEntry : SerializableBase
    {
        /// <summary>
        /// Length of a vertex table entry in bytes.
        /// </summary>
        public const int ENTRY_LENGTH = 4;

        /// <summary>
        /// X-location of the vertex.
        /// </summary>
        public Int16 X;

        /// <summary>
        /// Y-location of the vertex.
        /// </summary>
        public Int16 Y;

        /// <summary>
        /// Read vertex data.
        /// </summary>
        protected override void Read(Stream stream, int length)
        {
            DataReader reader = new DataReader(stream);
            X = reader.ReadInt16();
            Y = reader.ReadInt16();
        }

        /// <summary>
        /// Retrieve string representation of vertex.
        /// </summary>
        public override string ToString()
        {
            return "Vertex { Location=" +
                X.ToString() + ", " + Y.ToString() +
                "; }";
        }

        /// <summary>
        /// Write vertex data.
        /// </summary>
        protected override void Write(Stream stream)
        {
            DataWriter writer = new DataWriter(stream);
            writer.WriteInt16(X);
            writer.WriteInt16(Y);
        }
    }
}
